<template>
  <div :class="currentType === 'newConfig' ? 'new_wechat_modify' : 'wechat_modify'">
    <bread-crumb :titleArr="[$t('config.channel.WxManagement'), $t('public.edit')]" @back="back"></bread-crumb>
    <el-tabs class="wechat_tab" v-model.trim="activeMenu">
      <el-tab-pane :label="$t('webchat.basicInfo')" name="baseInfo" style="padding: 20px 0;">
        <weixin-auth-info v-if="type === 'Auth'" :weixindata="data"></weixin-auth-info>
        <weixin-dock-info v-if="type === 'Dock'" :weixindata="data"></weixin-dock-info>
        <platform-info v-if="type === 'Platform'" :weixindata="data"></platform-info>
      </el-tab-pane>
      <el-tab-pane :label="type === 'Auth'? $t('configLazyLoad.channel.wexinTip18') : $t('configLazyLoad.channel.wexinTip19')" name="customMenu"  style="padding: 20px 0;">
         <weixin-dock-step2 v-if="type === 'Dock'" :_id="data._id"></weixin-dock-step2>
         <wechat-auth-edit v-if="type === 'Auth'" :weixindata="data"></wechat-auth-edit>
         <platform-step v-if="type === 'Platform'" :formData="data" :wechatUrl="wechatUrl"></platform-step>
      </el-tab-pane>
      <el-tab-pane :label="'配置说明'"  v-if="type === 'Auth'">
        <webchatAuth></webchatAuth>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
  import webchatAuth from './wechatAuth.vue'
  import breadCrumb from './../../../../ui-modules/breadCrumb/BreadCrumbConfig.vue'
  import weixinAuthInfo from './wechatAuthInfo.vue'
  import wechatAuthEdit from './wechatAuthEdit.vue'
  import weixinDockInfo from './wechatDockInfo.vue'
  import weixinDockStep2 from './wechatDockStep2.vue'
  import platformInfo from './wechatPlatformInfo.vue'
  import platformStep from './wechatPlatformStep.vue'
  import { deepClone } from '@/utils/m7Utils'
  export default {
    name: 'wechatModify',
    data () {
      return {
        currenttab: '',
        activeMenu: 'baseInfo',
        wechatUrl: ''
      }
    },
    props: ['type', 'data'],
    methods: {
      back () {
        this.$emit('back')
      }
    },
    mounted () {
      if (this.type === 'Platform') {
        this.$store.dispatch('GetWeChatDock', {_id: this._id}).then(req2 => {
          console.log(req2)
          if (req2.success) {
            let url = deepClone(req2.wechatUrl)
            if (url.indexOf('http://') !== -1) {
              url = url.replace('http://', '')
            }
            if (url.indexOf('https://') !== -1) {
              url = url.replace('https://', '')
            }
            this.wechatUrl = url
          }
        })
      }
    },
    computed: {
      currentType () {
        let paths = this.$route.path.split('/')
        return paths[2]
      }
    },
    components: {
      breadCrumb,
      weixinAuthInfo,
      webchatAuth,
      weixinDockInfo,
      weixinDockStep2,
      wechatAuthEdit,
      platformInfo,
      platformStep
    }
  }
</script>

<style lang="stylus" scoped>
  .wechat_modify,.new_wechat_modify
    padding: 15px 15px 0;
    overflow-y: auto;
  .wechat_modify
    height: calc(100vh - 184px);
  .new_wechat_modify
    height: calc(100vh - 70px);
</style>
